//
//  DCCountDownHeadView.m
//  商城
//
//  Created by runone02 on 2018/8/27.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "DCCountDownHeadView.h"
#import "DCZuoWenRightButton.h"
/* 动画倒计时 */
#import "HSFTimeDownView.h"
#import "HSFTimeDownConfig.h"

@interface DCCountDownHeadView ()

/* 红色块 */
@property (strong , nonatomic)UIView *redView;
/* 时间 */
@property (strong , nonatomic)UILabel *timeLabel;
/* 倒计时 */
@property (strong , nonatomic)HSFTimeDownView *countDownLabel;
/* 好货秒抢 */
@property (strong , nonatomic)DCZuoWenRightButton *quickButton;
@end

@implementation DCCountDownHeadView

#pragma mark - Intial
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI {
    
    self.backgroundColor = [UIColor whiteColor];

    _timeLabel = [[UILabel alloc] init];
    _timeLabel.text = @"6点场";
    _timeLabel.font = TITLE_FONT(30);
    [self addSubview:_timeLabel];
    
    HSFTimeDownConfig *config = [[HSFTimeDownConfig alloc]init];
//    config.timeType = HSFTimeType_HOUR_MINUTE;
    config.bgColor = [UIColor redColor];
    config.fontColor = [UIColor blueColor];
    config.fontSize = 12.f;
    config.fontColor_placeholder = [UIColor orangeColor];
    config.fontSize_placeholder = 10.f;
    self.countDownLabel = [[HSFTimeDownView alloc] initWityFrame:CGRectMake(0, 0, 150, 20) config:config timeChange:^(NSInteger time) {
        NSLog(@"hsf===%ld",(long)time);
    } timeEnd:^{
        NSLog(@"hsf===倒计时结束");
    }];
    
    [self addSubview:self.countDownLabel];
    self.countDownLabel.center = self.center;
    
    [self.countDownLabel setcurentTime:60 * 60 * 20 * 3];  //设置倒计时时间

    [self addSubview:self.countDownLabel];
    
    _quickButton = [DCZuoWenRightButton buttonWithType:UIButtonTypeCustom];
    _quickButton.titleLabel.font = TITLE_FONT(25);
    [_quickButton setImage:IMAGE(@"shouye_icon_jiantou") forState:UIControlStateNormal];
    [_quickButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [_quickButton setTitle:@"好货秒抢" forState:UIControlStateNormal];
    [_quickButton addTarget:self action:@selector(quickButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_quickButton];

}

#pragma mark - 布局
- (void)layoutSubviews{
    [super layoutSubviews];
    
     WEAKSELF
    _redView = [[UIView alloc]init];
    _redView.backgroundColor = [UIColor redColor];
    [self addSubview:_redView];
    [_redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).with.offset(5);
        make.left.mas_equalTo(self).with.offset(5);
        make.bottom.mas_equalTo(self).with.offset(-5);
        make.width.mas_equalTo(5);
    }];
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.redView.mas_right).with.offset(10);
        make.centerY.mas_equalTo(weakSelf.redView);
        make.width.mas_equalTo(40);
    }];

    [_quickButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self).with.offset(-5);
        make.right.mas_equalTo(self).with.offset(-15);
        make.width.mas_equalTo(50);
    }];
    
    [_countDownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self).with.offset(-10);
        make.left.mas_equalTo(weakSelf.timeLabel.mas_right).with.offset(5);
        make.right.mas_equalTo(weakSelf.quickButton.mas_left).with.offset(-5);
    }];
}

- (void)quickButtonClick:(UIButton *)btn{
    NSLog(@"跳转好货秒抢界面");
}

#pragma mark - Setter Getter Methods


@end
